package com.bw.liuyushan.mykotlin_firstmvptest.Adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bw.liuyushan.mykotlin_firstmvptest.MVP.Entity.Data
import com.bw.liuyushan.mykotlin_firstmvptest.R
import kotlinx.android.synthetic.main.rv_food_layout.view.*

/**
 *MyKotlin_FirstTest
 *file name is : FoodAdapter
 *created by Ender on 2021/9/14 10:15.
 *author : 刘雨杉
 *Describe:
 */
class FoodAdapter(val data:MutableList<Data>) : RecyclerView.Adapter<FoodAdapter.ViewHolder>() {

    inner class ViewHolder(itemView: View) :RecyclerView.ViewHolder(itemView){
        var pic: ImageView = itemView.rv_pic
        var title: TextView = itemView.rv_title
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val inflate =
            LayoutInflater.from(parent.context).inflate(R.layout.rv_food_layout, null, false)

        val viewHolder = ViewHolder(inflate)
        return viewHolder
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val data1 = data[position]
        holder.title.text = data1.title
    }

    override fun getItemCount() = data.size
}